package com.wofish.common.core.domain;

import java.io.Serializable;

/**
 * Created by Administrator on 2016/6/9.
 */
public class JsonRsp<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    private int code;
    private boolean result;
    private String msg;
    private T data;

    public JsonRsp() {
    }

    public JsonRsp(Integer code) {
        this.code = code;
    }

    public JsonRsp(Integer code, Boolean result) {
        this.code = code;
        this.result = result;
    }

    public JsonRsp(Integer code, String reason) {
        this.code = code;
        this.msg = reason;
    }
    public JsonRsp(Integer code, Boolean result, String reason) {
        this.code = code;
        this.result = result;
        this.msg = reason;
    }

    public JsonRsp(Integer code, Boolean result, String reason, T data) {
        this.code = code;
        this.result = result;
        this.msg = reason;
        this.data = data;
    }

    public static JsonRsp setJsonRsp(JsonRsp jr, Integer code, Boolean result) {
        return setJsonRsp(jr, code, result, "", null);
    }

    public static JsonRsp setJsonRsp(JsonRsp jr, Integer code, Boolean result, String msg) {
        return setJsonRsp(jr, code, result, msg, null);
    }

    public static JsonRsp setJsonRsp(JsonRsp jr, Integer code, Boolean result, String reason, Object data) {
        if (jr != null) {
            jr.setCode(code);
            jr.setResult(result);
            jr.setMsg(reason);
            jr.setData(data);
        }
        return jr;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public Boolean getResult() {
        return result;
    }

    public void setResult(Boolean result) {
        this.result = result;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "JsonRsp{" + "code=" + code + ", resule=" + result + ", msg='" + msg + '\'' + ", data='" + data
            + '\'' + '}';
    }
}
